"""
难度：中等
输入一个非负整数数组，把数组里所有数字拼接起来排成一个数，打印能拼接出的所有数字中最小的一个。
示例 1:
输入: [10,2]
输出: "102"
示例 2:
输入: [3,30,34,5,9]
输出: "3033459"
"""
from typing import List

import functools
# from typing_extensions import TypeVarTuple
class Solution:
    def minNumber(self, nums: List[int]) -> str:
        def cmp(a,b):
            if a+b == b+a:
                return 0
            elif a+b > b+a:
                return 1
            else:
                return -1
        nums_s = list(map(str,nums))
        nums_s.sort(key=functools.cmp_to_key(cmp),reverse=False)
        return "".join(nums_s)
if __name__ == "__main__":
    s=[3,30,34,5,9]
    solu = Solution()
    print(solu.minNumber(s))
    # solu.minNumber(s)